﻿@model List<CinemaManagement.EF.Movie>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutUser.cshtml";
}

<main>
    <h2 class="text-center text-bg-light">电影院</h2>
    <div>
        <section id="loginForm">
            @using (Html.BeginForm("Index", "User", FormMethod.Post))
            {
                <input type="text" name="name" placeholder="按名称筛选" class="form-control flex-nowrap" />
                <input type="text" name="type" placeholder="按标签筛选" class="form-control text-nowrap" />
                <input type="submit" value="查找" class="btn btn-primary" />
            }
        </section>
    </div>

    <section id="MovieTable">
        <br />
        <table class="table table-striped table-bordered table-hover">
            <tr class="table-info">
                <th>电影名称</th>
                <th>电影类型</th>
                <th>电影演员</th>
                <th>电影时长</th>
                <th class="col-md-1">电影价格</th>
                <th>操作</th>
            </tr>
            @foreach (var m in Model)
            {
                <tr>
                    <td>@m.movieName</td>
                    <td>@m.movieType</td>
                    <td>@m.movieActor</td>
                    <td>@m.movieTime</td>
                    <td>@m.moviePrice</td>
                    <td>
                        <a href="@Url.Action("Details","User",new { movieId = m.movieId})">详情</a>
                    </td>
                </tr>
            }
        </table>
        <!-- 分页导航链接 -->
        @*<div>
            @if (Model.Count > 0)
            {
                int currentPage = ViewBag.Page ?? 1;
                int totalPages = ViewBag.TotalPages ?? 1;

                if (currentPage > 1)
                {
                    <a href="@Url.Action("Index", new { page = currentPage - 1 })">上一页</a>
                }

                for (int i = 1; i <= totalPages; i++)
                {
                    <a href="@Url.Action("Index", new { page = i })" @(currentPage == i ? "class=current" : "")>@i</a>
                }

                if (currentPage < totalPages)
                {
                    <a href="@Url.Action("Index", new { page = currentPage + 1 })">下一页</a>
                }
            }
        </div>*@
        <div>
            @if (Model.Count == 0)
            {
                @ViewBag.MovieNoFind
            }
            else
            {
                @ViewBag.TableFooter
            }
        </div>
    </section>
</main>